#include "Blocks/CottonBlock.h"
#include "Blocks/CottonWadBlock.h"
#include "Blocks/SeedsBlock.h"
#include "Blocks/ExperienceBlock.h"

namespace PocketSurvival
{
    void CottonBlock::getCreativeValues(std::vector<int32_t> &blockVec)
    {
        blockVec.push_back(Terrain::MakeBlockValue(Index(), 0, SetIsWild(SetSize(0, 2), true)));
        blockVec.push_back(Terrain::MakeBlockValue(Index(), 0, SetIsWild(SetSize(0, 1), false)));
        blockVec.push_back(Terrain::MakeBlockValue(Index(), 0, SetIsWild(SetSize(0, 2), false)));
    }

    void CottonBlock::getDropValues(int32_t oldValue, int32_t newValue, int32_t toolLevel, std::vector<BlockDropValue> &dropValues)
    {
        int32_t data = Terrain::ExtractData(oldValue);
        if (GetSize(data) == 2)
        {
            dropValues.emplace_back(Terrain::MakeBlockValue(SeedsBlock::Index(), 0, 6), m_random.getInt(1, 2));
            if (GetIsWild(data) == false)
            {
                int32_t num = m_random.getInt(1, 2);
                for (int32_t i = 0; i < num; i++)
                {
                    // dropValues.push_back(BlockDropValue { Terrain::MakeBlockValue(CottonWadBlock::Index(), 0, 0), 1 });
                    dropValues.emplace_back(Terrain::MakeBlockValue(CottonWadBlock::Index(), 0, 0), 1);
                }
                if (m_random.getBool(0.5f))
                {
                    // dropValues.push_back(BlockDropValue { Terrain::MakeBlockValue(248), 1 });
                    dropValues.emplace_back(Terrain::MakeBlockValue(ExperienceBlock::Index()), 1);
                }
            }
        }
    }

    const std::vector<BoundingBox> &CottonBlock::getCustomCollisionBoxes(int32_t value)
    {
        return BlockConstans::defaultCollisionBoxes;
    }

    int32_t CottonBlock::getIndex()
    {
        return Index();
    }
    const std::string &CottonBlock::getBlockName()
    {
        static std::string blockName = "CottonBlock";
        return blockName;
    }

} // namespace PocketSurvival
